added nil handling