Implement logging (could also need some testing)