refactored scope and layout