Fix nil point access error