changed controller loop to reduce thread overhead