refactored layouting