finished some parsing work with error handling