b: Refactor the code