readded sorting some odd code still running round but it works