added an alternative implementation