fixed the bug in prior calculation