improved logging

just wrote a function for logging