cleaned up code, added comments, added a basic example