Fixed null pointer runtime error