Refactor using obsever pattern