This code should be put inside a dedicated service ...