clean up code, add comment