a bit of debugging and reorganizing