Restructed Code and store all info in DB