fixed bugs discovered in testing