this fixed the ordering, but does it really have to be that complex?