fixing imports and refactoring a bit