some reussable java code