Refactored allscript.js