working out a bug