added toArray function
use item class for working with items instead of direct db calls
code style fixes