1st version completed with very slow execution.