refactor code chunks