fix bug: malloc all the time