NPM should take most recent version

NPM should by default take the most up-to-date one if it has a range of options from what is supplied.  

Also added some if statements to prevent it from crashing in the case where it can't find a matching version.