Fixed helper function