implemented #57, redirect can be a function