fixed malloc bug