refactoring setposition function
refactoring setposition function