more generic layout selector, fixes #38