redo this crap, let's not use php