some bug fixes to define