fixing cast warnings