error management added.better integration with server