Extract parsing code as a method