Added error handling WIP