Replaced code with my code

Added error handling, only thing missing is the XML parsing.