firstNotNull method duplication removed