add common functioanlity
fixed #5 + cleanup