Refactored source code from Manuel Kiessling's "The Node Beginner Book"