Factorized code
Completed migration of the code