working on finishing all functionality. some refactoring