Refactored implementation to allow for rules - rules still broken