basket js refactoring