Fix the name of the drush function. Fix enless loop bug and clean up some logic to reduce number of lines in code. Add drush logging