null check doesn't really work; use if in locals()