Optimise function slightly.