Adding retry and better exception handling