Memory allication error fix