Cleaned code in move function