implement in vanilla js