added some optimizing from database loading