some changes in logic