fixed single function for general case