changed  calculating positions