using fnil rather than if statement