RF: simplify code, get rid of for loop