fixed faulty flow