more error checking and configuration - code clean up