Refactored and made servlet work