JajaScript optimisation (and fucking simplification)