counter and slide optimization