Finally modified and works