finish most of functionality