working on success and error functions