Refactor whole JS file : better handling of multiple-call requests