algorithm4