Move function refactoring
Minor fixes in move fumction