updated based on latest gist iteration