fixed sub in place bug