Refactored and simplified everything