finished rewrite with same functionality, plus ifdb searching