Change if-not nil? to if because nil is falsey value