Method `redirect` does not work correctly