code moving and refactoring