Streamlined the helper functions and fixed a bug with the redirects