Changed if-guard to capture cases correctly.