refactoring a lot. again..