Apply layout algorithm