cleaned up code for readability