Added comments and changed move function