Refactor to split validation and send back
First function is working in UI