Fix Undefined index on 1st check