postgres formula is causing issues :(