implemented some bug fixes