Added check for prime chains