fixed bugs with loading from db