fixed order of to lines, so that tableentries are only created when the condition is met