use collect instead of map for partial function