refactor layout code, major UI change