fixing memory issues