made size caldulations more robust