fixing 'cannot call empty? on nil' error