Added try-except block