Fix Beginning/Trailing Spaces on Classes

I applied the trim function to string class before it is split what caused an error output if it had beginning or trailing spaces.