started refactoring malloc