using signed int for cast was incorrect