Fixed wrong logic