bug fixes to end