This is before cleaning up the code.