refactored null return to optional