js functions reduction