improved version of the kwic function