check space first and then update iteration index