Fixed algorithm issue and some whitespace.