Fixed code to remove runtime warnings