cleaned up code, ready to submit