Completely refactored