add mode logic