updated code to fix windows Visual Studio errors