resubmitting code, cleaned up and ready