added ordering ability flag
fixed crucial bugs. first working version