modified to work with modern browsers