Made functions for flexible

changes the move function.  NEVER use a while(true) inside a function,
It is bad coding convention.