restructured javascript, added object