the side-effect of shift() is hiding in this line