better exception handling and nio2 file handling