Copied a more elegant version of web.js