fixed javascript overlapping each other functions