Code is improved. Verifier is added to check capacity constraints.