generic parser method