could not resist fixing a few bugs