complete

completed code and added comments