Refactor to avoid singleton