Added guard before passing db result