fix wrong malloc (resolves issue 1)