Use correct json structure
Improve function to build actions