Lab4 working code