core logic complete, shortens and redirects