fix bugs relating to singular replace