lots of refactoring
refactoring magic