shorten looping-go function