Adding success and failure functions for formatting responses.