Refactor + testing added