refactor layout code. for deck mgr