added some bug fixes