fix bug of calculating factor