change constructor to accept regular javascript object