This is a rails version of my math pbat