modified to compible with VS 2012