Fixed duplicated when condition