Implemented suggestions from @mezzoblue