adding some function interface, comments and psudo code