Simplified code a bit, fixed output method type