modified Kirk script for my own understanding.