added stack sort