added documentation
fixed a bug, added documentation