haukex has pointed out one problem with your use of shift. If this were the only problem, you could use
splice instead. However, neither will work because both require an array (not a list). The difference is subtle, but the documentation of both have it right.