rewrite layout calculator