refactor code with forEach, bind, filter, and map