I hope this code is nicely written...