Fix bug in width calculation