Finally works, duplicate code though, must read on node.js further