Some improves for error handling and proper queries for server side