refactoring + find declaration improvements (but implementation is really dirty)