Remove unnecessary function
Add function for dart usage; change scope of variables