refactor with OOJS to seperate concerns