Implementation of  subroutine: the steps of the snake