added some stuff to make custom url smarter
clean up