can remove a lot of dead code because of try-with-resources