Refactored it a bit. Form validation doesn't work right now.