fixed bugs throughout