algo of luan to complete