Centralising JS code