simplify and better naming
deal with the empty data frame
useless line
typo