function.bail
added null check