cleaned up and added documentation