added if to iterate over mongo collection