modified redrawUnit function