Create hook mechanism. Refactor