fixed bugs & outputs