fix cast and use an int