Change to new architecture using functions