everything working, will do some refactoring