fixing a few bugs