optimized setting vars, now only does it when necessary