revised the complete algorithm part