added credit for mathematical formula I used.