some refactoring and added control of physics