Refactor javascripts
Make it work with transfer