Fixed bug, added documentation