rewrote control handling