Default implementation of this feature is simple, but optimisation is rather challenging here. So if you have any fresh ideas to optimise it further, you're welcome :)