add comments and sync from luna's code