Client side validation added, some refactor