Check `if (callback && typeof callback === 'function')` here and below.