restructured for flask, again