refactoring

created helper function to strip chars from a string, made code easier
to read.