moved flash message after using api into use_api method on the providers