Added isNil to prevent undefined error