Fixed the runtime error stopping the whole code