Added comments and typescript definition by Zik