big refactor of js object