random code from my university, you don't want to fork this