the rest of cs program and minor modification