refactor former func to log and create new function to create request