fixed p24 to be much more efficient