TODO: reduce code duplication with 
