Fix memory issue