removed unused count var and cleaned header