Fixed bug in compensation code, upped version