Real algorithm working!