Fixed bug of sometimes leaving the last character out