Optimize JPA; Modify algorithm to all handlers