Refactored to use prototypes