lab7. disclaimer: i have almost no idea what the code is doing :S