Cleaned up and commented for submission