improved parsing rules