Code formatted to avoid duplication