Adding code to check for completion