Update common-functions.js

cleaned it up a bit