Restructring for readability and code reuse