improve declaration matcher to handle more cases