implemented null safe positive and negative checks. Used recursive match instead of for loop.