move this to the beginning of the func?