refactored layout, time remaining function.