refactored to make alternative implementation consistent