moved function inside object construction