added documentation and removed some IO