refacor out restc to common util, add saveIM