code flow improvements (forEach)