fix algorithm hw