Simplified and cleaned up