better parsing, still buggy