Added try/catch clauses for higher robustness