improvements: comments + replace global statements