code cleanup (remove duplicate code)