I wonder if we shall move this function to a more global position - e.g. js.js - maybe useful in other locations as well