modify phases and some indentation