Untested fix for ending, did this shit at work!