update semi-working code