Moved check before switch statemet.