cleaned up code to follow same style as before