Extract variables outside if() statements