basic iterative function working