refactor compact for code clarity