Minor: we're mixing commenting styles in the same piece of code (// and #), would be better to stick to just one, doesn't matter which as far as is consistent throughout the file.