take mode as parameter?