changed variable assignment function