fixed logic for computer algorithm