updated for efficiency