First version without errors (but presumably slow)