brought up to date with the code and change ordering