implemented take without tail rec.