stab at solution...need to reduce usage of pop to mak emore efficient