refactored some code, all code is untested in any way...