fixed bugs from screwed-up commit