add algorithm interface and error handling