add finalize method to cleanup native resource