Moving function to a helper