fixed bugs found in testing