Switched remaining jQuery code to pure JavaScript