JavaScript tidying