done some refactoring and added new features