changed apis and updated style a bit