Encapsulate ifactions

Encapsulated ifactions into a proper API
Fixed error message