thanks to Allan for the code formatting. Seems that I'm too stupid to do it myself...