fixed the exception in the end