Working code using layouts