Improved error handling

Source readability enhancement