Groovy script for automatically logging hours in JIRA

Hello everyone,
We have written a script in Script Runner that automatically log hours for users. The script works okey (log hours for different users) but
we have found a bug where the Logged field gets only the last log hours, not all, like shown in the picture bellow.

Can someone have an idea how this can be done?