Fixed algorithm and added include.