updated voting logic and added validatoin