Extract the logic as separate hooks service and integrate it with commands service