Rewrote order in Perl, added some features