main function added, majority of functionality should be there.