Move logic to controllers