Change callbacks to be more functional (thanks @manishtomar)