A bug which turns strings to object in loops where an if clause is present