Fixing nil access error