minor changes & code refactoring js