added proper resource disposing