Refactor compact for code clarity

No logic change. Just for code clarity.