refactor before each block