Added code to check for flush