adding logging and argument checks