How to optimize the existing approach