refactor function blocks