check null only once