@XD1v0: Thank you very much! That did the trick. Although I don't understand this completely, because pan_str is a local string which should already be initialized. (see beginning of the function)
@shinobi: Thank you too! Thats indeed quite a nice function to know off, might come in handy in the future.