added a conditional check