new size function
Finally fixed all memory corruptions