update size calculation to consider special cases