refactor using map and filter fns