changed purchase function