fix duplicate code