Changed error handling

Removed the secondary onError callback function for error handling,
instead, errors are now returned as the first parameter of the  main
callback function.