rewrote LSU calculator's algorithm
merge with john's stuff