added "smart" capture code