Fixed crashing bug by adding try/catch