implement buy and history