improve context search and bug fix