Bug algorithms code