Working version with typescript