some fix based on mark's feedback