moved error check logic to serverside