cleaned up the code, and added examples