Ifelse now finished, time to complete forloops.