changed entire code