generic exp implementation