This is the implementation of each function, with javascript