Fixed error getting max order