updated main method and mem_alloc appears to be functioning correctly