finished buy functions and views