working pillbox

still needs some refactoring to avoid looping through full entity list