added error parameter to callbacks to adopt nodejs pattern