Replaced switch for if-else for speed in parseTo method