changing to js. adding some functionality.