Fixed layout issues with David's code