cleaned up to be more generic