Move width CSS setting code into a function

see #25