copied all of alan's code, mwahaha