Working dynamic allocation and read from array