just a bit refactored