conditional check for type