working code now