mission tested and little bit refactored