bugfix: ln 874 when components.size()==0 gets stuck in loop due to -1