cleaned up and commented for submission