Fixed error message popping up at wrong time.