refactored a bunch of shit and added prototypical inheritance