fixed ordering bugs