Removed unused variable and added in cast to prevent compiler warnings.