code refractoring + log file added