added client-side data validation