cleaned up code, wrote documentation