made some changes and error fixes