Simplified code a little bit