Beautify scary javascript