define functions outside of loops