fix bug in conditional check