refactor to move code to contract analyzer