implementation of other person's python script on http://hivecolor.com/id/60