Add simple function and fix bugs