made some changes into Adams code: into calculateVectorR method