fixed input bug FOR GOOD. added lots of comments