bug fixes for unreachable code