added new delegate method. moved random angle generator to C function