fixing memory issue