move endprogremm-function to controls.cpp