edit tiles position and refactor code