functions and controls execution depending on current window