updated cube handler with flushInput