Refactor to do testing