simple functional loop handler