Tookout memory and clock into own function