Fixed the crash at the end