uery script adapted from Pixedelic