finished own algorithm