modified for VS2010