use macro to refacor