neater code and more commenting