filled out the update snake function.
merged code