I don't think that the conditions should go in the same if because the log error. You may have livereload enabled but the lr variable not instanciated.