factoring out common vars