Correct algo but still not working