add function(sub) to main.js

Again, I ask you for a check