Improved logic; added comments.
Testing issue on DigitalOcean.