modified the contract subroutine