Fixed nil value error on conditional check