moved conditional check