fixed a few bugs