Fixed null reference pointer bug