compatibility with vs2008, functions can use arguments, added cast to return value