Seperated token validation to standalone function