add returns and fix some bugs