bug fix, subroutine cast()