move switching to own method