helper function for flask