working code with null and static references