-- minor performance optimization
-- added implementation of imreduce