Bug free, but serious optimisation required