Added typecast and removed bad assignment