Cleaned up and slightly refactored