bug fixes to prevent incorrect errors