String function

Working on my string function, making some variables local,
as well as fixing a few errors that were messing with my codes flow