Code clean up in provider factory