massive optimisation by reducing call to db to one