Refactor remove null check and use Java 8 Optional