cleaned up code for better reading