added documentation, fixed formatting