Error handling and showing alerts added