modulized from Jan's sugestion