improved take function