Fixed Whitespace bug

Wrote a simpler whitespace removal function.