Updated parsing code, slightly more compact code using sscanf