add error handling, and explictly return callback if there is one