made some bug fixes