Changed Javascript Logic