Finish random function