some changes to code