clean up to prevent URL overlap
update to handle nils