Move layout validity logic to separate method