fix direct and inverse functions