Prettied up javascript to be more consistent