enhance error detection and messages related to improper 'next' and 'context' usages