reduce redundant code