refactoring due to changes in application
moar refactoring and bugfix