Simplified code slightly