ToEnum: updated to cut out empty spaces out of the string