removing duplicate and restructuring