implementing replace (not working well for space)