refactored to match new requirements