applet algorithm