changed error handeling and file reading