Added runtime error handling