Optimize backend button click function