Optimize this check a little