refactor code for upvote/downvote