added most of functionality