did some refactoring and cleaned up