Completly refactored