calculate size rather than pass it around