# Identical code behaving differently

**URL:** <https://forum.makecode.com/t/identical-code-behaving-differently/15378>\
**Category:** Help\
**Created:** [September 16, 2022, 2:35am UTC](https://forum.makecode.com/t/identical-code-behaving-differently/15378 "2022-09-16T02:35:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jaturn68](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jaturn68/32/2180_2.png) [@jaturn68](https://forum.makecode.com/u/jaturn68)\
**Post date:** [September 16, 2022, 2:35am UTC](https://forum.makecode.com/t/identical-code-behaving-differently/15378/1 "2022-09-16T02:35:29Z")

</div>

The code in these 2 links are, as far as I can tell, identical (they should be).

However in this link: [https://makecode.com/\_easfvg9H28v7](https://makecode.com/_easfvg9H28v7) - Bubbles (player) is NOT extending her arms when she climbs the wall which she should, as demonstrated in this link: [https://makecode.com/\_Lae3rDaCXRF2](https://makecode.com/_Lae3rDaCXRF2)

Again, the code in these 2 links are identical - I’m having a hard time wrapping my head around why they perform differently. Please help!

---

<div class="post-metadata">

**Author:** ![Vegz78](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/vegz78/32/1201_2.png) [@Vegz78](https://forum.makecode.com/u/Vegz78)\
**Post date:** [October 5, 2023, 4:54pm UTC](https://forum.makecode.com/t/identical-code-behaving-differently/15378/2 "2023-10-05T16:54:49Z")

</div>

Hi again @jaturn68,

This was an interesting small quirk which I did not know about:

It turns out that the code is identical for both except in sequence/priority, in that the game.onUpdate() function has priority in exeution depending on which one is positioned the furthest up on the block canvas or in the underlying JavaScript code, ceteris paribus.

Only flipping the relative positions of the two game.onUpdate() function around for the first link that does not work, will give it the same working functionality with arms extending while climbing as the working second link, and vica versa.

A more robust solution, where the correct order is guaranteed for every game update loop, could perhaps be to put everything in the right order in the same and only one game.onUpdate() function, like this:

> **[End of Lesson 5 video](https://arcade.makecode.com/37505-47131-75413-55140)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

---

<div class="post-metadata">

**Author:** ![jaturn68](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jaturn68/32/2180_2.png) [@jaturn68](https://forum.makecode.com/u/jaturn68)\
**Post date:** [October 9, 2023, 4:59pm UTC](https://forum.makecode.com/t/identical-code-behaving-differently/15378/3 "2023-10-09T16:59:20Z")

</div>

Wow this makes total sense, never would have thought of it. I appreciate you taking the time to look at this and explain it so well. Thank you so much!!!
