malloc almost complete.. should just need to edit memIndex