rayn NPE problem fixed with try-finally