js file refractored and added fadeIn effect