add more error handling
refactory code
add server side code