exam code refactor