moving code and adding purchase completion (incomplete)