Added error handling to add item functionality