calculate array size properly