deleted inline because function is used only once in demos
added missing returning value
deleted unused variables
added missing const in declaration