Refactoring the maincode. Now just nodejs server