Take code out of function