Refactor web and separate JS