fixes and added lot of functionality