rand method to be improved