a bit refactored