modified nearest prime