sort reverse completed. code need to be refactored