Sorted out Sam's string parsing function,