order actions correctly and merge them