moving setting the common vars outside the mode logic