some modifications.. working code