Implement algorithm