moving log into else block