Fixed error "A critical error has occurred. Object reference not set to an instance of an object."