fixed bugs with constructor