Fixing potential runtime error