Remove function, replace with sql manip