was returning the value before the last redirection instead of after