Moved random number logic to controller