Refactor to avoid more static variables