addded more callbacks to functions for better err handing