Modified to better support multiple uses on a page