extract createOnNull as separate class and macro