Refactor to make code more compact.