fixed  a few bugs