Split kxp calculator into own function