first attempt and shift left function, changed srandom to srand