updated with logging