move logic to gist.js