fix layout detection