Re-implemented the logger. Now a bit more efficient