fixed memory issues