try to find correct variable based on key or value