Refactor layout ctrl