described the methods and constructor, refactored for modern browsers