added better control handling