Splitted javascript logic from index.html