completed refactor of simple malloc