Added logging and functions