performance optimisation - previous version introduced significant performance degradation