Refactored to support AMD