Refactor clear_level