refactored acording to patterns of scalable js apps