Design of multistage activated sludge-biofilm reactors: a rational approach