Added final code with migration