Factoring out width calculation