Hi valoronions,
I don’t see anything wrong with your function, which suggests that it’s to do with the element that you’re putting in. Are you able to post the bit of code that’s using the function (I appreciate you not posting everything - my code for this level was ~150 lines ).
There’s a topic here where someone had the same error - it’s in python, but it might give you some clues about what’s happening.
Jenny