code to handle url