used try with resource construct from java 7