few changes added some more de-duplication