fixed a bug in constructor