fix substitute taking a count to work correctly