Tidying up JS