moved function def around for read flow