Just a couple of changes to maintain the original logical flow, reenable error handling and simplify the code.