reduced duplication statements in function
tried to debug extra ;
got output to console