code written from Reddit's daily Programmer subreddit