fixed minor bugs in replace_letters