fixed bugs, added output testing