refactored to split layoutService into a separate file