shortened some code in the log function