Working fine, except layout algorithm