Fix bug when passing undefined as optional callback