proper size_t/int casting to prevent compiler warnings