implemented handling reirects