modernized & cleaned up a bit