solved security policy issue, simplified logic.