self executing function complete fixed several errors