snake functioning working on reverse direction