added handle_end to .h