using weakhashmap to allow garbage collection