minor changes in logic