resets if snake goes out of bounds.
refactoring of code.