Introduced proper error handling and display