Simplified code a bit.