move retry transaction logic into module, and moved set validation sql query into class and replaced strings with Arel.