Refactored servlet and added a few comments