optimize handler code (minimize backend calls)