refactored to use foreman-api