update bin script to be a bit smarter