extracted function for determining result