converted from tabs to spaces, and inserted randomness into effort func