Extract code to Modules - Private function
extract logic to appropriate locations